package cj.web.tb.dao;

import java.util.List;
import java.util.Map;

import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import cj.web.tb.domain.TBRaterRegistration;

@DAO
public interface TBNetInterfaceDAO {
	//专家
	@SQL("SELECT * FROM TBRaterRegistration WHERE deleteFlag=1 AND type=:1 AND STATUS=1 ORDER BY updateAt DESC LIMIT :2,:3 ")
    List<Map> queryRaterRegByType(int type,int start,int length);
	
	@SQL("SELECT COUNT(1) FROM TBRaterRegistration WHERE deleteFlag=1 AND type=:1 AND STATUS=1")
    int queryRaterRegByTypeSize(int type);
	
	@SQL("SELECT * FROM TBRaterRegistration WHERE id=:1")
    TBRaterRegistration queryRaterRegById(int id);
	
	//学校
	@SQL("SELECT * FROM TBSchoolRegistration WHERE deleteFlag=1 AND STATUS=1 #if(:1 != null){ AND areaName LIKE '%##(:1)%' } ORDER BY updateAt DESC LIMIT :2,:3 ")
    List<Map> querySchoolReg(String areaName,int start,int length);
	
	@SQL("SELECT COUNT(1) FROM TBSchoolRegistration WHERE deleteFlag=1 AND STATUS=1 #if(:1 != null){ AND areaName LIKE '%##(:1)%' } ")
    int querySchoolRegSize(String areaName);
	
	@SQL("SELECT a.areaName,a.schoolName,a.schoolModel,a.classNum,c.grade,c.name,c.teacher from TBSchoolRegistration a "
			+ "JOIN TBRecommendation b ON a.userId=b.userId "
			+ "JOIN TBRecommendationItem c ON b.id=c.recommendationId "
			+ "WHERE a.deleteFlag=1 AND b.deleteFlag=1 AND c.deleteFlag=1 AND a.id=:1 AND a.status=1 AND b.status=4 ")
    List<Map> querySchoolRegItemById(int id);
}
